package org.example.service.impl;

import org.apache.dubbo.config.annotation.Service;
import org.example.service.HelloService;

import java.util.Random;

/**
 * Description: 提供3个方法（sayHello1、sayHello2、sayHello3），每方法都实现了随机休眠0-100ms
 * Author: e
 * CreateDate: 2021-05-19
 */
@Service
public class HelloServiceImpl implements HelloService {


    public long random() {
        Random random = new Random();
        return random.nextInt(100);
    }

    @Override
    public String sayHello1(String name) {
        try {
            Thread.sleep(random());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "hello1:" + name;
    }

    @Override
    public String sayHello2(String name) {
        try {
            Thread.sleep(random());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "hello2:" + name;
    }

    @Override
    public String sayHello3(String name) {
        try {
            Thread.sleep(random());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "hello3:" + name;
    }
}
